/**
 * 
 */
package com.tvshows.front.listener.command;

import com.tvshows.front.controllers.dialog.ActionsController;
import com.tvshows.front.factory.TypeUI;
import com.tvshows.front.factory.ViewFactory;
import com.tvshows.front.listener.command.interfaces.FavoriteCommand;
import com.tvshows.front.ui.dialog.ActionsUI;
import com.tvshows.front.ui.favorite.UpsideCompositeFavoriteUI;
import com.tvshows.front.view.dialog.ActionsView;
import com.tvshows.structure.bdd.BddQueries;

/**
 * @author Tangi Midy
 */
public class AddFavoriteCommand
    extends FavoriteCommand
{

    /**
     * the {@link UpsideCompositeFavoriteUI}
     */
    private UpsideCompositeFavoriteUI upsideComposite;

    /**
     * The {@link ActionsView}
     */
    ActionsUI actionsView;

    /**
     * Constructeur prend un {@link UpsideCompositeFavoriteUI} en paramètre
     */
    public AddFavoriteCommand( UpsideCompositeFavoriteUI upsideComposite )
    {
        this.upsideComposite = upsideComposite;
    }

    /**
     * @see com.tvshows.front.listener.command.interfaces.FavoriteCommand#executeCommand()
     */
    public void executeCommand()
    {
        if ( !BddQueries.getBddQueries().isJobRunning() )
        {
            actionsView = (ActionsUI) ViewFactory.getUI( TypeUI.ACTIONS_VIEW );
            actionsView.openShell( upsideComposite );
        }
        else
        {
            ActionsController.popUpJobRunning( upsideComposite );
        }
    }

}
